unit OptionsForm1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, EllipsLabel, Grids, ValEdit,mail_consts, AdvGlowButton,
  mail_ChkProc,mail_msg;

type
  TOptionForm = class(TForm)
    ValueListEditor1: TValueListEditor;
    EllipsLabel1: TEllipsLabel;
    btnSetOK: TAdvGlowButton;
    btnSetCnsl: TAdvGlowButton;
    procedure FormCreate(Sender: TObject);
    procedure btnSetOKClick(Sender: TObject);
    procedure btnSetCnslClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  OptionForm: TOptionForm;

implementation

{$R *.dfm}

procedure TOptionForm.btnSetCnslClick(Sender: TObject);
begin
  Self.ModalResult:=mrCancel;
end;

procedure TOptionForm.btnSetOKClick(Sender: TObject);
begin
  if chk_Host(Self.ValueListEditor1.Values[c_valLstStr[1]])=-1
    then msgWrongHost
    else
      if chk_SMTPPort(Self.ValueListEditor1.Values[c_valLstStr[2]])=-1
        then msgWrongSMTPPort
        else
          if chk_Email(LowerCase(Self.ValueListEditor1.Values[c_valLstStr[4]]))=-1
            then msgWrongEmail
            else
              if chk_Savepwd(LowerCase(Self.ValueListEditor1.Values[c_valLstStr[5]]))=-1
                then msgWrongSavePWD
                else
                  if chk_OnePerMail(Self.ValueListEditor1.Values[c_valLstStr[6]])=-1
                    then msgWrongOnePerMail
                    else
                      if chk_BD(Self.ValueListEditor1.Values[c_valLstStr[7]])=-1
                        then msgWrongBDPath
                        else Self.ModalResult:=mrOk;
end;

procedure TOptionForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if Self.ModalResult<>mrOk then Self.ModalResult:=mrCancel;
end;

procedure TOptionForm.FormCreate(Sender: TObject);
var i:integer;
begin
  Self.Caption:=c_capOptionForm;
  OptionForm.EllipsLabel1.Caption:=c_hlpOptions;
  btnSetOK.Caption:=c_capBtnSetOK;
  btnSetCnsl.Caption:=c_capBtnSetCnsl;
  ValueListEditor1.Strings.Clear;
  For i:=1  to 7 do ValueListEditor1.Strings.Add(c_valLstStr[i]+'=');
end;

end.
